- Brief intro to the elements of shiny
- How shiny can help make your work more accessible
- Examples
2022-06-17
app.R, and create your app starting from a snippetA shiny app is made up of two parts: the ui that defines how it looks and the server which defines how it works.
library(shiny)
ui <- fluidPage(
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
Content that is added to the UI displays to the user.
library(shiny)
ui <- fluidPage(
"Hello, CDS!"
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
Outputs which are rendered on the server side can be displayed by the ui.
You have to tell the ui what sort of object is being rendered:
plotOutput() ~ renderPlot()tableOutput() ~ renderTable()leafletOutput() ~ renderLeaflet()Many of these are in {shiny} but some will be in their respective packages ({leaflet} for the last one)
ui <- fluidPage(
plotOutput("plot")
)
server <- function(input, output, session) {
output$plot <- renderPlot({
hist(rnorm(n=20))
})
}
shinyApp(ui, server)
ui <- fluidPage(
plotOutput("plot")
)
server <- function(input, output, session) {
output$plot <- renderPlot({
hist(rnorm(n=20))
})
}
shinyApp(ui, server)
ui <- fluidPage(
numericInput("sample_size", "Select sample size:", value=20),
plotOutput("plot")
)
server <- function(input, output, session) {
output$plot <- renderPlot({
hist(rnorm(n=input$sample_size))
})
}
shinyApp(ui, server)
funs <- ls("package:shiny")
funs[grepl("input$", tolower(funs)) & !grepl("update", tolower(funs))]
## [1] "checkboxGroupInput" "checkboxInput" ## [3] "dateInput" "dateRangeInput" ## [5] "fileInput" "numericInput" ## [7] "passwordInput" "restoreInput" ## [9] "selectInput" "selectizeInput" ## [11] "sliderInput" "snapshotPreprocessInput" ## [13] "textAreaInput" "textInput" ## [15] "varSelectInput" "varSelectizeInput"
(Also see {shinyWidgets} for some fun input options)
ui <- fluidPage(
checkboxGroupInput('checkboxGroupInput', 'checkboxGroup:', choices=LETTERS[1:3], selected="A"),
splitLayout(dateInput("dateInput", "date:"), fileInput("fileInput", "file:")),
shinyWidgets::colorSelectorInput("colorSelectorInput", "colorSelector:", c("red", "green", "blue"), "red"),
shinyWidgets::downloadBttn("downloadBttn")
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
{circacompare}App that allows users to upload their data and fit a nonlinear model (using nls()) that estimates differences in circadian characteristics between two groups.
https://rwparsons.shinyapps.io/circacompare/
Most use the R package but sometimes, they will say that they specifically used the shiny app.
This app visualises inequity in access to traumatic brain injury care across QLD.
https://access.healthequity.link/
| https://rwparsons.github.io/interactive-maps/ |
|
|
|
|
@Rex_Parsons8
@RWParsons
Slides were made using ioslides_presentation in RMarkdown